<?php

namespace App\Model;

use EasySwoole\ORM\AbstractModel;
use EasySwoole\Pool\Manager;

/**
 * Class ActivityBetModel
 * Create With Automatic Generator
 * @property $id
 * @property $name
 */
class ActivityBetModel extends AbstractModel
{
    protected $tableName = 'bee_activity_bet';

    protected $primaryKey = 'id';

    public function getTypeMap()
    {
        $redis = Manager::getInstance()->get('redis')->getObj();
        $temp = [];
        if ($redis->exists('all_consume_type_map')) {
            $temp = json_decode($redis->get('all_consume_type_map'), true);
        } else {
            $info = $this->all();
            foreach ($info as $one) {
                $temp[$one->id] = [
                    'name' => $one->name,
                    'multiple' => $one->multiple,
                ];
            }
            $redis->set('all_consume_type_map', json_encode($temp));
            Manager::getInstance()->get('redis')->recycleObj($redis);
        }
        return $temp;
    }
}